#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include <sys/mman.h>

#define err(msg) perror(msg)

int main(void)
{
    int fd;
    char *addr;

    if ((fd = open("/dev/lv", O_RDWR)) == -1)
    {
        err("open");
        goto err;
    }
    
    addr = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
    if (addr == MAP_FAILED)
    {
        err("mmap");
        goto err2;
    }
    strcpy(addr, "this is a mmap test\n");
		printf("test success\n");
	printf("%s",addr);
    munmap(addr, 4096);
    close(fd);
    return 0;
err2:
    close(fd);
err:
    return -1;
}

